<!-- 原材料炉号生产零件信息表 -->
<template>
  <div>
    <div class="searchbox">
      <el-form :inline="true" size="small" label-width="100px">
        <jt-easy-collapse :has-expand="true">
          <template slot="expand">
            <el-form-item label="原材料炉号：">
              <el-input size="small" placeholder="原材料炉号" v-model="form.materialFurnanceNumber"></el-input>
            </el-form-item>
            <el-form-item label="日期">
              <el-date-picker v-model="form.fromDate" type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder=""></el-date-picker>
            </el-form-item>
            <el-form-item label="至" label-width="25px">
              <el-date-picker v-model="form.toDate" type="date" value-format="yyyy-MM-dd HH:mm:ss" placeholder=""></el-date-picker>
            </el-form-item>
             <!-- <el-form-item label="日期:">
               <el-date-picker size="small"  :default-time="['00:00:00', '23:59:59']" value-format="yyyy-MM-dd HH:mm:ss" v-model="date" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"  style="width: 420px">
               </el-date-picker>
            </el-form-item> -->
            <el-form-item style="margin-left: 20px;">
              <el-button size="mini" type="primary" @click= "showList()">查询</el-button>
            </el-form-item>
            <el-form-item>
              <el-button size="mini" @click="clenaFrom">清除</el-button>
            </el-form-item>
          </template>
        </jt-easy-collapse>
      </el-form>
    </div>
    <div class="contentbox">
      <el-button size="small" type="primary" @click="getExcel()">导出清单</el-button>
      <!-- 表格 -->
      <h2 style="text-align: center;">原材料炉号生产零件信息表</h2><br>
      <h3 style="text-align: center;"  v-if="form.fromDate != '' && form.toDate != ''">{{this.form.fromDate.slice(0,10)}}至{{this.form.toDate.slice(0,10)}}</h3><br>
      <el-table :data="tableData" border style="width: 90%;margin: 0 auto;">
        <el-table-column prop="heatingNumber" label="热处理炉号" width="180"></el-table-column>
        <!-- <el-table-column prop="date" align="center" label="2-18.06.07 ~ 2018.07.07"> -->
          <el-table-column prop="applyTime" label="报验日期" width=""></el-table-column>
          <el-table-column prop="auditTime" label="报告完成日期" width=""></el-table-column>
          <el-table-column prop="partNumber" label="零件号" width=""></el-table-column>
          <el-table-column prop="partName" label="零件名称" width=""></el-table-column>
          <el-table-column prop="partGraphNumber" label="零件图号" width=""></el-table-column>
          <el-table-column prop="quertity" label="报验数量" width=""></el-table-column>
          <el-table-column prop="testResult" label="结论" width=""></el-table-column>
        <!-- </el-table-column> -->
      </el-table>
    </div>
  </div>
</template>

<script>
import {
 getMaterialFurnance,getMaterialFurnance1
} from "service/task";
  import JtEasyCollapse from 'components/jt-easy-collapse/index';
  export default {
    name: 'RemindingCenter',
    components: {
      'jt-easy-collapse': JtEasyCollapse,
    },
    data() {
      return {
        date:"",
        form: {
          materialFurnanceNumber: "",
          fromDate: "",
          toDate: ""
        },
        tableData: []
      }
    },
    mounted() {
    // this.showList();
    },
    methods: {
       getExcel() {
      if(this.form.fromDate == "" || this.form.fromDate==null || this.form.fromDate == " " ||
      this.form.toDate == "" || this.form.toDate==null || this.form.toDate == " "){
          this.$message({
            type: 'error',
            message: '请选择起止时间!'
          });
          return;
        }
        window.location.href= `${process.env.API_URL}` + "report/getInformationExcel?materialFurnanceNumber=" + this.form.materialFurnanceNumber
         + "&startDate=" + this.form.fromDate + "&endDate=" + this.form.toDate;
    },
    clenaFrom(){
      this.form = {};
      this.date="";
    },
    // 表格数据展示
    showList() {
      if(this.form.fromDate == "" || this.form.fromDate==null || this.form.fromDate == " " ||
      this.form.toDate == "" || this.form.toDate==null || this.form.toDate == " "){
          this.$message({
            type: 'error',
            message: '请选择起止时间!'
          });
          return;
        }
      let params = {
        materialFurnanceNumber: this.form.materialFurnanceNumber,
        fromDate: this.form.fromDate,
        toDate: this.form.toDate
        // fromDate: this.date[0],
        // toDate: this.date[1]
      };
      this.loading = true;
      getMaterialFurnance(params).then(res => {
        // alert(this.date[0].slice(0,10));
        // alert(this.date[1].slice(0,10));
        // for(let i=0;i<res.data.result.list.size;i++){
        //   var dateee = new Date(res.data.result.list[i].applyTime).toJSON();
        //   dateee =new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
        //   res.data.result.list[i].setApplyTime=dateee;
        // }
        this.tableData = res.data.result.list;
        this.tableData.forEach(e => {
          if(e.applyTime!=null && e.applyTime!='' && e.applyTime!=' '){
            var dateee = new Date(e.applyTime).toJSON();
            dateee =new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
            e.applyTime = dateee;
          }
          if(e.reportTime!=null && e.reportTime!='' && e.reportTime!=' '){
            var dataaa = new Date(e.reportTime).toJSON();
            dataaa =new Date(+new Date(dataaa) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
            e.reportTime = dataaa;
          }
        })
      });
    },
    // 表头展示
    getTableHeaderLabel(str) {
      return this.getTableSomeValue(str, "alias");
    },
    // 获取表格列的宽度
    getTableColumnWidth(str) {
      return this.getTableSomeValue(str, "width");
    },
    // 获取表格列是否是固定的
    getTableColumnFixed(str) {
      return this.getTableSomeValue(str, "fixed");
    },
    // 获取表格列是否排序
    getTableColumnSort(str) {
      return this.getTableSomeValue(str, "sort");
    },
    // 获取表格表头，列宽度，列固定，列排序的值
    getTableSomeValue(str, keyName) {
      for (var value of this.tableHeaderArr) {
        if (value["name"] == str) {
          return value[keyName];
        }
      }
    }
     }
  }

</script>
